home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 27 / CU Amiga Magazine's Super CD-ROM 27 (1998)(EMAP Images)(GB)[!][issue 1998-10].iso / CUCD / Programming / THXPlayLib / src / note.asm < prev    next >
Encoding:
Assembly Source File  |  1998-05-10  |  5.4 KB  |  185 lines

  1. ; note: these routines simply alter the data accessed in interrupt.asm
  2. ; this data is defined at the bottom of this source
  3.  
  4. ;****** thxplay.library/thxPlayNote ******************************************
  5. ;
  6. ;   NAME
  7. ;       thxPlayNote -- start playing a user-specified note.
  8. ;
  9. ;   SYNOPSIS
  10. ;       void thxPlayNote(channel, note,   instrument)
  11. ;                        D0-0:1   D1-0:5  D2-0:5
  12. ;
  13. ;       void thxPlayNote(ULONG, ULONG, ULONG);
  14. ;
  15. ;       thxPlayNote(channel, note, instrument)
  16. ;
  17. ;   FUNCTION
  18. ;       Plays  one of the instruments in the THX module at a particular note
  19. ;       on  a particular channel. It is up to you to ensure that the channel
  20. ;       you  play  the  note  on is empty and so will not interfere with the
  21. ;       note  being  played.  This function is to allow you to play your own
  22. ;       notes  during  THX  play,  for  example  as  part of a game as sound
  23. ;       effects.  The  note  played is subject to the same conditions as the
  24. ;       song itself, such as the global volume control. In addition, you can
  25. ;       apply  'FX'  commands to the note. In effect, what is happening when
  26. ;       you  call  thxPlayNote()  is  that  the  'track data' for the chosen
  27. ;       channel being played is overwritten (not the module itself, just the
  28. ;       sound output). It is overwritten on the first line by your specified
  29. ;       instrument  with  note  and  FX,  then  on  consecutive lines by the
  30. ;       'blank'  note and instrument. This 'overwriting' stops only when you
  31. ;       call thxStopNote(), or stop the module naturaly.
  32. ;
  33. ;   INPUTS
  34. ;       channel    - The channel on which the note is played, from 0 to 3.
  35. ;       note       - The halfnote (pitch) at which the instrument is to be
  36. ;                    played, from 1 (C-1) to 60 (B-5).
  37. ;       instrument - an instrument from the song, from 1-63. You should know
  38. ;                    which instrument you want to play!
  39. ;
  40. ;   EXAMPLE
  41. ;       thxPlayNote(2, 8, 12) is equivalent to this in THX Sound System's
  42. ;       tracker view:
  43. ;
  44. ;       ---00000 | ---00000 | G-112000 | ---00000
  45. ;       ---00000 | ---00000 | ---00000 | ---00000
  46. ;       ---00000 | ---00000 | ---00000 | ---00000
  47. ;       [...]
  48. ;
  49. ;   SEE ALSO
  50. ;       thxStopNote(), thxNoteFX()
  51. ;
  52. ;****************************************************************************
  53. ;
  54. ;
  55.     cnop    0,4
  56. thxPlayNote
  57.     ifd    STACKARGS
  58.     move.l    12(sp),d0
  59.     move.l    8(sp),d1
  60.     move.l    4(sp),d2
  61.     endc
  62.  
  63.     and.w    #%11,d0
  64.     mulu.w    #bn_SIZEOF,d0
  65.     lea    _notes(pc,d0.w),a0    ; select notes[channel]
  66.  
  67.     move.b    d1,bn_note(a0)        ; notes[channel].note := note
  68.     move.b    d2,bn_ins(a0)        ; notes[channel].ins  := instrument
  69.     st.b    (a0)            ; notes[channel].on   := true
  70.     rts
  71.  
  72.  
  73.  
  74.  
  75. ;****** thxplay.library/thxStopNote ******************************************
  76. ;
  77. ;   NAME
  78. ;       thxStopNote -- stop playing user-specified note.
  79. ;
  80. ;   SYNOPSIS
  81. ;       void thxStopNote(channel)
  82. ;                        D0-0:1
  83. ;
  84. ;       void thxStopNote(ULONG);
  85. ;
  86. ;       thxStopNote(channel)
  87. ;
  88. ;   FUNCTION
  89. ;       Stops  anything you started with thxPlayNote(). Please be aware that
  90. ;       notes  which  don't  fade  away  on  their own will first need to be
  91. ;       silenced with thxNoteFX($C, $00), or such
  92. ;
  93. ;   SEE ALSO
  94. ;       thxPlayNote()
  95. ;
  96. ;****************************************************************************
  97. ;
  98. ;
  99.     cnop    0,4
  100. thxStopNote
  101.     ifd    STACKARGS
  102.     move.l    4(sp),d0
  103.     endc
  104.  
  105.     and.w    #%11,d0
  106.     mulu.w    #bn_SIZEOF,d0
  107.     lea    _notes(pc,d0.w),a0    ; select notes[channel]
  108.  
  109.     clr.b    (a0)            ; notes[channel].on := false
  110.     rts
  111.  
  112.  
  113.  
  114.  
  115. ;****** thxplay.library/thxNoteFX ******************************************
  116. ;
  117. ;   NAME
  118. ;       thxNoteFX -- perform FX command on user-specified channel.
  119. ;
  120. ;   SYNOPSIS
  121. ;       void thxNoteFX(channel, command, parameter)
  122. ;                      D0-0:1   D1-0:3   D2-0:7
  123. ;
  124. ;       void thxNoteFX(ULONG, ULONG, ULONG);
  125. ;
  126. ;       thxNoteFX(channel, command, parameter)
  127. ;
  128. ;   FUNCTION
  129. ;       Performs  an  effect command on the particular channel. You can call
  130. ;       this  at  any  time,  even before you play the note, if you want the
  131. ;       note  to  start  off  with an initial effect. See THX Sound System's
  132. ;       documentation for the full list of commands and their parameters.
  133. ;
  134. ;   INPUTS
  135. ;       channel   - The channel affected
  136. ;       command   - the effect command, eg $C is the Set Volume command.
  137. ;       parameter - the parameter to the command, eg $40 is full volume.
  138. ;
  139. ;   NOTE
  140. ;       No  validation  of  the  command  or  its  parameter is done. Beware
  141. ;       feeding wrong or out of range values. Range for command is $0 to $F,
  142. ;       parameter is $00 to $FF.
  143. ;
  144. ;   SEE ALSO
  145. ;       thxPlayNote()
  146. ;
  147. ;****************************************************************************
  148. ;
  149. ;
  150.     cnop    0,4
  151. thxNoteFX
  152.     ifd    STACKARGS
  153.     move.l    12(sp),d0
  154.     move.l    8(sp),d1
  155.     move.l    4(sp),d2
  156.     endc
  157.  
  158.     and.w    #%11,d0
  159.     mulu.w    #bn_SIZEOF,d0
  160.     lea    _notes(pc,d0.w),a0    ; select notes[channel]
  161.  
  162.     and.b    #$F,d1
  163.     move.b    d1,bn_fx(a0)        ; notes[channel].fx    := command
  164.     move.b    d2,bn_fxval(a0)        ; notes[channel].fxval := parameter
  165.     rts
  166.  
  167.  
  168.  
  169.  
  170.     STRUCTURE bangnote,0
  171.     UBYTE    bn_on        ; BOOL bang in effect
  172.     UBYTE    bn_note        ; UBYTE (1-63) instrument to bang
  173.     UBYTE    bn_ins        ; UBYTE (0-60) halftone to bang at
  174.     UBYTE    bn_fx        ; UBYTE ($0-$F) fx command for bang
  175.     UBYTE    bn_fxval    ; UBYTE ($00-$FF) fx parameter
  176.     LABEL    bn_SIZEOF
  177. ; this structure order is depended on in _playnote of interrupt.asm
  178.  
  179. ; VARIABLES
  180. _notes
  181. chan0    dcb.b    bn_SIZEOF,0
  182. chan1    dcb.b    bn_SIZEOF,0
  183. chan2    dcb.b    bn_SIZEOF,0
  184. chan3    dcb.b    bn_SIZEOF,0
  185.